# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=svt-av1
pkgver=1.8.0
pkgrel=0
pkgdesc="Scalable Vector Technology for AV1 encoder (SVT-AV1 Encoder)"
url="https://01.org/svt"
# 32-bit is not supported upstream
# https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/master/CMakeLists.txt#L40
arch="all !x86 !armhf !armv7"
license="BSD-3-Clause-Clear"
options="!check" # No test suite from upstream
makedepends="cmake samurai nasm"
subpackages="
	$pkgname-dev
	libSvtAv1Dec:declib
	libSvtAv1Enc:enclib
	"
source="https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$pkgver/SVT-AV1-v$pkgver.tar.bz2"
builddir="$srcdir/SVT-AV1-v$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	export LDFLAGS="$LDFLAGS -Wl,-z,stack-size=1048576"
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

declib() {
	amove usr/lib/libSvtAv1Dec.so.*
}

enclib() {
	amove usr/lib/libSvtAv1Enc.so.*
}

sha512sums="
2d8af4a2f81c0c5b5aabe33ac84da6a0dcc23d6ca03ac581dbc2de6e4df5db2ceb53d0d54720eac3969ed863ffd8ce1293dbf5b6275118f0f80a99825eca94b3  SVT-AV1-v1.8.0.tar.bz2
"
